package freshmanspecial.mredrock.com.welcomefreshman.View;

import android.content.res.Resources;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.util.TypedValue;
import android.view.View;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TextView;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;

import freshmanspecial.mredrock.com.welcomefreshman.Adapter.MyPagerAdapter;
import freshmanspecial.mredrock.com.welcomefreshman.Base.BaseActivity;
import freshmanspecial.mredrock.com.welcomefreshman.Fragment.MienBeaFragment;
import freshmanspecial.mredrock.com.welcomefreshman.Fragment.MienCreFragment;
import freshmanspecial.mredrock.com.welcomefreshman.Fragment.MienOrgFragment;
import freshmanspecial.mredrock.com.welcomefreshman.Fragment.MienStuFragment;
import freshmanspecial.mredrock.com.welcomefreshman.Fragment.MienTeaFragment;
import freshmanspecial.mredrock.com.welcomefreshman.Presenter.MienPresenter;
import freshmanspecial.mredrock.com.welcomefreshman.R;

/**
 * Created by Administrator on 2017/8/6 0006.
 */

public class MienView extends BaseActivity implements IMienView{
    private ImageButton btn_backToMainView;
    private MienPresenter presenter;
    private TabLayout tabLayout;
    private TextView text_title;
    private ViewPager viewPager;
    private List<Fragment> list;
    private MyPagerAdapter adapter;
    private String[] titles = {"学生组织","原创重邮","美在重邮","优秀教师","优秀学生"};
    @Override
    protected void initData() {
        presenter = new MienPresenter(this);
        btn_backToMainView = $(R.id.btn_back);
        text_title = $(R.id.text_titlebar);
        text_title.setText("重邮风采");
        tabLayout = $(R.id.mien_tab);
        viewPager = $(R.id.mien_pager);
        list = new ArrayList<>();
        list.add(new MienOrgFragment());
        list.add(new MienCreFragment());
        list.add(new MienBeaFragment());
        list.add(new MienTeaFragment());
        list.add(new MienStuFragment());
        adapter = new MyPagerAdapter(getSupportFragmentManager());
        adapter.setTitles(titles);
        adapter.setFragments(list);
        viewPager.setOffscreenPageLimit(5);
        tabLayout.post(new Runnable() {
            @Override
            public void run() {
                setIndicator(tabLayout,25,25);
            }
        });
        viewPager.setAdapter(adapter);
        tabLayout.setupWithViewPager(viewPager);
        setBackToMainView();
    }

    @Override
    protected int getContentViewId() {
        return R.layout.special_2017_mienview;
    }

    @Override
    public void setBackToMainView() {
        btn_backToMainView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                presenter.backToMainView();
            }
        });
    }
}
